package com.zkkj.demo.web;

import com.zkkj.demo.annotation.FilterToken;
import com.zkkj.demo.entity.LoginUser;
import com.zkkj.demo.service.LoginService;
import com.zkkj.demo.vo.base.AResultVo;
import com.zkkj.demo.vo.base.BaseResultVo;
import com.zkkj.demo.vo.base.ResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * author : cyc
 * Date : 2019/12/24
 */

@RestController
@RequestMapping(value = "login")
@Api(value = "登录api", description = "登录api文档")
public class LoginController {

    @Autowired
    private LoginService loginService;

    @ApiOperation(value = "用户登录接口", notes = "用户登录接口api")
    @PostMapping(value = "login")
    public AResultVo<String> login(@RequestBody LoginUser loginUser) {
        AResultVo<String> aResultVo = new ResultVo<>();
        return aResultVo.success(loginService.login(loginUser));
    }

    @ApiOperation(value = "测试接口1", notes = "测试接口1api")
    @GetMapping(value = "hello")
    @FilterToken
    public AResultVo<String> hello(@RequestParam String args) {
        AResultVo<String> aResultVo = new ResultVo<>();
        return aResultVo.success("hello world " + args);
    }

    @ApiOperation(value = "测试接口2", notes = "测试接口api2")
    @GetMapping(value = "test")
    public AResultVo<String> test(@RequestParam String args) {
        AResultVo<String> aResultVo = new ResultVo<>();
        return aResultVo.success("test " + args);
    }
}
